// IP protocols (icmp, udp and tcp) header and packet handling

#ifndef IP_H
#define IP_H

#include "eth.h"
#include "pci.h"

// ip packet types - header
#define IP_TYPE_ICMP	0x01 
#define IP_TYPE_UDP  	0x11
#define IP_TYPE_TCP  	0x06

// ip header struct
struct ipHeader_t
{
	uint8_t verlen;
	uint8_t tos;
	uint16_t len;
	uint16_t id;
	uint16_t frag;
	uint8_t ttl;
	uint8_t type;
	uint16_t checksum;
	uint32_t ipSrc;
	uint32_t ipDest;
}__attribute__((packed));

// ip header type
typedef struct ipHeader_t ipHeader_t;

// handles ip stuff
int ipSendPacket( ethernet_t *eth, int ipDest, packet_t *p, uint8_t type, int allchksum );
void handleIpPacket(ethernet_t *eth, packet_t *pkt);
void *ipStripHeader(packet_t *p);

// converts a string to an ip
int strToIp( char* str );

#endif // IP_H